import type { App } from 'vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import Button from './components/Button'
import Alert from './components/Alert'
import Collapse, { CollapseItem } from './components/Collapse'
import Dropdown from './components/Dropdown'
import Form from './components/Form'
import Icon from './components/Icon'
import Message, { createMessage, closeAll } from './components/Message'
import Select from './components/Select'
import Switch from './components/Switch'
import Tooltip from './components/Tooltip'

import './styles/index.css'

library.add(fas)

const components = [
  Button,
  Alert,
  Collapse,
  CollapseItem,
  Dropdown,
  Form,
  Icon,
  Message,
  Select,
  Switch,
  Tooltip,
]

const install = (app: App) => {
  components.forEach((component) => {
    app.component(component.name!, component)
  })
}

export {
  install,
  Button,
  Alert,
  Collapse,
  CollapseItem,
  Dropdown,
  Form,
  Icon,
  Message,
  Select,
  Switch,
  Tooltip,
  createMessage,
  closeAll,
}

export default install
